﻿using System;
using System.Globalization;
using System.IO;

namespace Flowertwig.Utils
{
    public class AssemblyOperations
    {
        protected static CultureInfo _cultureInfo = CultureInfo.GetCultureInfo("en-GB");

        public static double GetRunningVersionNumber(object obj)
        {
            double version = 0.0;
            if (obj == null)
                throw  new ArgumentNullException("obj can not be null.");
            try
            {
                string filename = obj.GetType().Assembly.Location;
                var fi = new FileInfo(filename);
                string strVersion = string.Format("{0:yyyyMMdd.hhmm}", fi.LastWriteTime);
                double.TryParse(strVersion, NumberStyles.Float, _cultureInfo.NumberFormat, out version);
            }catch { }

            return version;
        }
    }
}
